	var IfStatusData = [{
		id:'',
		name:'全部',
		'selected':'true'
	},{
		id:'0',
		name:'停用'
	},{
		id:'1',
		name:'启用'
	}];
	
	var IfAuditStatusData = [{
		id:'',
		name:'全部',
		'selected':'true'
	},{
		id:'0',
		name:'未审核'
	},{
		id:'1',
		name:'已审核'
	}];
	
	
	var requestMethod = [{
		id:'0',
		name:'GET'
	},{
		id:'4',
		name:'POST'
	}];

	var isModify = true;
	//定位显示
	var arrayLi = [];
	var arrayLiInd = 0;
	
	var deleteParamIds ="";
	var httpBundleId = "";
	
	var authModeTotal = [{
		valueName:"免认证",
		valueCode:"0"
	},{
		valueName:"Http-Basic-Key",
		valueCode:"1"
	},{
		valueName:"Oauth认证",
		valueCode:"2"
	},{
		valueName:"WS-Security",
		valueCode:"3"
	}];
	
	
	$(document).ready(function(){
		
		//导入
		$('#import_link').window({
			width:465,
			modal:true,
			minimizable:false,
			maximizable:false,
			collapsible:false
		});
		$('#import_link').window('close');  //关闭窗口
		
		
		$("#selFileBtn").click(function(e){
			e.preventDefault();
			//$("#file").click();
		});

		
		$("#import_form").delegate("#file" ,"change", function() {
		    $("#fileName").val($('#file').val());
		    //clearAutofillStyle();
		});
		
		
		//导入
		$('#import_link_ftp').window({
			width:465,
			modal:true,
			minimizable:false,
			maximizable:false,
			collapsible:false
		});
		$('#import_link_ftp').window('close');  //关闭窗口
		
		
		$("#selFileBtn_ftp").click(function(e){
			e.preventDefault();
			//$("#file").click();
		});

		
		$("#import_form_ftp").delegate("#file_ftp" ,"change", function() {
		    $("#fileName_ftp").val($('#file_ftp').val());
		    //clearAutofillStyle();
		});
		
		
		
		//alert("sldflsd");
		$('#comboxSearchField').combobox({
			url: BASE_URL_FIELD_SEARCH + '/findAllOfCurrentUserCanManage' + '?v=' + Math.random(),
			valueField: 'id',
		    textField: 'name',
		    editable: false,
		    method:'get',
		    loadFilter: function(data){
		    	var allCheck = {'id':'','name':'全部'};
		    	data.content.unshift(allCheck);
		    	return data.content;
		    },
		    onSelect: function(record){
		    	comboxSearchSystemName.combobox({
                    disabled: false,
                    method:'get',
                    queryParams: {fieldId: record.id},
                    url: BASE_URL_FIELD_SYSTEM_SEARCH +'/findByFieldOfCurrentUserCanManage' + '?v=' + Math.random(),
                    valueField: 'id',
                    textField: 'name',
					data:'',
        		    loadFilter: function(data){
        		    	var allCheck = {'id':'','name':'全部'};
        		    	data.content.unshift(allCheck);
        		    	return data.content;
        		    },
        		    onLoadSuccess:function(){
        		    	comboxSearchSystemName.combobox('setValue','');
        		    }
                }).load();
		    },
		    onLoadSuccess:function(){
		    	$('#comboxSearchField').combobox('setValue','');
		    }
		});
		
		//所属系统下拉框
		var comboxSearchSystemName = $('#comboxSearchFieldSystem').combobox({
            disabled: true,
            valueField: 'id',
            textField: 'name',
            editable: false,
		  data:[{id:'',name:'全部','selected':'true'}]
        });
		
		var comboxInterfaceStatus = $('#comboxInterfaceStatus').combobox({
            valueField: 'id',
            textField: 'name',
            editable: false,
		  	data:IfStatusData
        });
		
		
		var comboxAuditStatus = $('#comboxAuditStatus').combobox({
            valueField: 'id',
            textField: 'name',
            editable: false,
		  	data:IfAuditStatusData
        });
		
		
		
		//ftp
		$('#comboxSearchField_ftp').combobox({
			url: BASE_URL_FIELD_SEARCH + '/findAllOfCurrentUserCanManage' + '?v=' + Math.random(),
			valueField: 'id',
		    textField: 'name',
		    editable: false,
		    method:'get',
		    loadFilter: function(data){
		    	var allCheck = {'id':'','name':'全部'};
		    	data.content.unshift(allCheck);
		    	return data.content;
		    },
		    onSelect: function(record){
		    	comboxSearchSystemName_ftp.combobox({
                    disabled: false,
                    method:'get',
                    queryParams: {fieldId: record.id},
                    url: BASE_URL_FIELD_SYSTEM_SEARCH +'/findByFieldOfCurrentUserCanManage' + '?v=' + Math.random(),
                    valueField: 'id',
                    textField: 'name',
					data:'',
        		    loadFilter: function(data){
        		    	var allCheck = {'id':'','name':'全部'};
        		    	data.content.unshift(allCheck);
        		    	return data.content;
        		    },
        		    onLoadSuccess:function(){
        		    	comboxSearchSystemName_ftp.combobox('setValue','');
        		    }
                }).load();
		    },
		    onLoadSuccess:function(){
		    	$('#comboxSearchField_ftp').combobox('setValue','');
		    }
		});
		
		//所属系统下拉框
		var comboxSearchSystemName_ftp = $('#comboxSearchFieldSystem_ftp').combobox({
            disabled: true,
            valueField: 'id',
            textField: 'name',
            editable: false,
		  data:[{id:'',name:'全部','selected':'true'}]
        });
		
		var comboxInterfaceStatus_ftp = $('#comboxInterfaceStatus_ftp').combobox({
            valueField: 'id',
            textField: 'name',
            editable: false,
		  	data:IfStatusData
        });
		
		
		var comboxAuditStatus_ftp = $('#comboxAuditStatus_ftp').combobox({
            valueField: 'id',
            textField: 'name',
            editable: false,
		  	data:IfAuditStatusData
        });
		
		
		$("#datagrid_http").datagrid({
			url : BASE_URL_HTTP_INTERFACE_SEARCH + '/findHttpInterfacesByUser?v='+Math.random(),
			method:'get',
			autoRowHeight:true,
			singleSelect:false,
			striped:true,
			nowrap:false,
			pageSize:20,
			pageList:[10,20,50,100],
			columns:[[
						{field:'',width:10,checkbox:true},
						{field:'fieldName',title:'领域',width:80},
						{field:'systemName',title:'系统',width:70},
						{field:'interfaceType',title:'接口类型',width:120},
						{field:'interfaceName',title:'接口名称',width:115},
						{field:'interfaceCode',title:'接口编码',width:115},
						{field:'createdDate',title:'注册时间',width:150},
						{field:'auditStatus',title:'审核状态',width:60},
						{field:'interfaceVersion',title:'版本',width:70},
						{field:'bundleName',title:'bundle编号',width:120},
						{field:'interfaceStatus',title:'接口状态',width:60,
							formatter: function(value,row,index){
								if(value == 0){
									return "已停用"
								}else if(value == 1){
									return "已启用"
								}
							}
						}
			      ]],
			pagination:true,
			loadFilter:function(data){
				//alert("inData:"+JSON.stringify(data));
				return {
					total: data.totalElements,
					rows: data.content
				};
			},
			onSelect:function(rowIndex, rowData){
				if(rowData.interfaceType=='FTP'){
					$('#toolbar_upgrade').linkbutton('disable');
				}else{
					$("#toolbar_upgrade").linkbutton('enable');
				}
			},
			onBeforeLoad:function(param){
				param.page -= 1;
				param.size = param.rows;
				delete param.rows;
				
				param.sort = 'createTime,desc';
				var fieldId = $('#comboxSearchField').combobox('getValue');
				if(fieldId !=""){
					param.fieldId = fieldId;
				}else{
					param.fieldId = "";
				}
				
				var fieldSystemId = $('#comboxSearchFieldSystem').combobox('getValue');
				if(fieldSystemId !=""){
					param.fieldSystemId = fieldSystemId;
				}else{
					param.fieldSystemId = "";
				}
				var Status = $('#comboxInterfaceStatus').combobox('getValue');
				if(Status !=""){
					param.Status = Status;
				}else{
					param.Status = "";
				}
				
				var auditStatus = $('#comboxAuditStatus').combobox('getValue');
				if(auditStatus !=""){
					param.auditStatus = auditStatus;
				}else{
					param.auditStatus = "";
				}
				 
				var name = $('#interfaceName').val();
				if(name !=""){
					param.name = name;
				}else{
					param.name = "";
				}
				
				var code = $('#serachInterfaceCode').val();
				if(code !=""){
					param.code = code;
				}else{
					param.code = "";
				}
				
				param["createTime"] = $("#txtCreateTimeBeg").datetimebox('getValue');
				param["endTime"] = $("#txtCreateTimeEnd").datetimebox('getValue');
			}
		});
		
		$("#datagrid_http").datagrid('getPager').pagination({   
		    displayMsg:'当前显示从 [{from}] 到 [{to}] 共[{total}]条记录'
		}); 
		
		$(".button_con a" ).removeClass("l-btn-plain");
		
		
		//ftp
		$("#datagrid_ftp").datagrid({
			url : BASE_URL_HTTP_INTERFACE_SEARCH + '/findFtpInterfacesByUser?v='+Math.random(),
			method:'get',
			autoRowHeight:true,
			singleSelect:false,
			striped:true,
			nowrap:false,
			pageSize:20,
			pageList:[10,20,50,100],
			columns:[[
						{field:'',width:10,checkbox:true},
						{field:'fieldName',title:'领域',width:80},
						{field:'systemName',title:'系统',width:70},
						{field:'interfaceType',title:'接口类型',width:120},
						{field:'interfaceName',title:'接口名称',width:115},
						{field:'interfaceCode',title:'接口编码',width:115},
						{field:'createdDate',title:'注册时间',width:150},
						{field:'auditStatus',title:'审核状态',width:60},
						{field:'interfaceVersion',title:'版本',width:70},
						{field:'bundleName',title:'bundle编号',width:120},
						{field:'interfaceStatus',title:'接口状态',width:60,
							formatter: function(value,row,index){
								if(value == 0){
									return "已停用"
								}else if(value == 1){
									return "已启用"
								}
							}
						}
			      ]],
			pagination:true,
			loadFilter:function(data){
				//alert("inData:"+JSON.stringify(data));
				return {
					total: data.totalElements,
					rows: data.content
				};
			},
			onSelect:function(rowIndex, rowData){
				if(rowData.interfaceType=='FTP'){
					$('#toolbar_upgrade').linkbutton('disable');
				}else{
					$("#toolbar_upgrade").linkbutton('enable');
				}
			},
			onBeforeLoad:function(param){
				param.page -= 1;
				param.size = param.rows;
				delete param.rows;
				
				param.sort = 'createTime,desc';
				var fieldId = $('#comboxSearchField_ftp').combobox('getValue');
				if(fieldId !=""){
					param.fieldId = fieldId;
				}else{
					param.fieldId = "";
				}
				
				var fieldSystemId = $('#comboxSearchFieldSystem_ftp').combobox('getValue');
				if(fieldSystemId !=""){
					param.fieldSystemId = fieldSystemId;
				}else{
					param.fieldSystemId = "";
				}
				var Status = $('#comboxInterfaceStatus_ftp').combobox('getValue');
				if(Status !=""){
					param.Status = Status;
				}else{
					param.Status = "";
				}
				
				var auditStatus = $('#comboxAuditStatus_ftp').combobox('getValue');
				if(auditStatus !=""){
					param.auditStatus = auditStatus;
				}else{
					param.auditStatus = "";
				}
				 
				var name = $('#interfaceName_ftp').val();
				if(name !=""){
					param.name = name;
				}else{
					param.name = "";
				}
				
				var code = $('#serachInterfaceCode_ftp').val();
				if(code !=""){
					param.code = code;
				}else{
					param.code = "";
				}
				
				param["createTime"] = $("#txtCreateTimeBeg_ftp").datetimebox('getValue');
				param["endTime"] = $("#txtCreateTimeEnd_ftp").datetimebox('getValue');
			}
		});
		
		$("#datagrid_ftp").datagrid('getPager').pagination({   
		    displayMsg:'当前显示从 [{from}] 到 [{to}] 共[{total}]条记录'
		}); 
		
		$(".button_con a" ).removeClass("l-btn-plain");
		
		
	});
		
		
	
	//导出
	function onExport(){
		var rows = $('#datagrid_http').datagrid('getSelections');
		if(rows.length == 0){
 			$.messager.alert('警告',"<p>请选中要导出的记录!</p>","warning");
 			return ;
 		}
		var ids = "";
		for(var i=0; i< rows.length;i++){
			ids += (ids == ""? "":",") + rows[i].interfaceId;
		}
		location.href= BASE_URL_EXPORTDATA_FILE + '/httpInterfaceExport?param='+ids;
	}
	
	//导入
	function onImport()
	{
		$('#import_link').window('open'); 
	}

	function startImport() {
		if($("#file").val() == "")
		{
			$.messager.alert("警告", "<p>请选择需要导入的.xls或.xlsx格式的文件</p>", 'warning');
			return;
		}
		var tempArr = $("#file").val().split(".");
		var selFileType = tempArr[tempArr.length - 1];
		if(selFileType != "xls" && selFileType != "xlsx")
		{
			$.messager.alert("警告", "<p>选择的文件格式有误，请选择.xls或.xlsx格式的文件</p>", 'warning');
			return;
		}
		$("#buttons_inport .easyui-linkbutton").linkbutton("disable");
		$("#buttons_inport .l-btn-text").text("正在导入...");
	 		
		//$("#import_form").submit();
		$.ajaxFileUpload({
	        url: '/api/importData/httpInterface/fileUpload' + "?name=" + encodeURI($("#fileName").val()), 
	        type: 'post',
	        secureuri: false, //一般设置为false
	        fileElementId: 'file', // 上传文件的id、name属性名
	        dataType: 'text', //返回值类型，一般设置为json、application/json
	        //data: "name=" + encodeURI($("#fileName").val()), //传递参数到服务器
	        success: function(data, status){
	        	
	     		$("#buttons_inport .easyui-linkbutton").linkbutton("enable");
	     		$("#buttons_inport .l-btn-text").text("确定导入");
	     		
	        	//var resultObj = eval("[" + data.activeElement.innerText + "]")[0];
	        	var resultObj = JSON.parse(data.slice(data.indexOf(">") + 1,data.indexOf("</")));
	            if(resultObj.backValue === true)
	            {
		            $("#fileName").val($('#file').val());
	            	$('#import_link').window('close'); 
	            	$('#datagrid_http').datagrid('reload');
	            	$.messager.alert('提示',"<p>导入成功！</p>", 'info');
	            }
	            else if(resultObj.backValue === false)
	            {
		            $("#fileName").val($('#file').val());
	            	//$.messager.alert('错误',"<p>导入失败!所选文件内容为空或存在异常！</p>","error");
		            $.messager.alert('错误',"<p>" + resultObj.errorDesc + "</p>","error");  
	            }
	            else
	            {
		            $("#fileName").val($('#file').val());
	            	$.messager.alert('错误',"<p>导入失败！" + resultObj.backValue + "</p>", "error"); 
	            }
	        },
	        error: function(data, status, e){ 
	            $("#fileName").val($('#file').val());
	     		$("#buttons_inport .easyui-linkbutton").linkbutton("enable");
	     		$("#buttons_inport .l-btn-text").text("确定导入");
	     		
	        	$.messager.alert('错误',"<p>导入失败!</p>","error");
	        }
	    });
	}
	
	function onSearch(){
		$('#datagrid_http').datagrid('reload');
	}
	
	
	//ftp
	//导出
	function onExport_ftp(){
		var rows = $('#datagrid_ftp').datagrid('getSelections');
		if(rows.length == 0){
 			$.messager.alert('警告',"<p>请选中要导出的记录!</p>","warning");
 			return ;
 		}
		var ids = "";
		for(var i=0; i< rows.length;i++){
			ids += (ids == ""? "":",") + rows[i].interfaceId;
		}
		location.href= BASE_URL_EXPORTDATA_FILE + '/ftpInterfaceExport?param='+ids;
	}
	
	//导入
	function onImport_ftp()
	{
		$('#import_link_ftp').window('open'); 
	}

	function startImport_ftp() {
		if($("#file_ftp").val() == "")
		{
			$.messager.alert("警告", "<p>请选择需要导入的.xls或.xlsx格式的文件</p>", 'warning');
			return;
		}
		var tempArr = $("#file_ftp").val().split(".");
		var selFileType = tempArr[tempArr.length - 1];
		if(selFileType != "xls" && selFileType != "xlsx")
		{
			$.messager.alert("警告", "<p>选择的文件格式有误，请选择.xls或.xlsx格式的文件</p>", 'warning');
			return;
		}
		$("#buttons_inport_ftp .easyui-linkbutton").linkbutton("disable");
		$("#buttons_inport_ftp .l-btn-text").text("正在导入...");
	 		
		//$("#import_form").submit();
		$.ajaxFileUpload({
	        url: '/api/importData/ftpInterface/fileUpload' + "?name=" + encodeURI($("#fileName_ftp").val()), 
	        type: 'post',
	        secureuri: false, //一般设置为false
	        fileElementId: 'file_ftp', // 上传文件的id、name属性名
	        dataType: 'text', //返回值类型，一般设置为json、application/json
	        //data: "name=" + encodeURI($("#fileName").val()), //传递参数到服务器
	        success: function(data, status){
	        	
	     		$("#buttons_inport_ftp .easyui-linkbutton").linkbutton("enable");
	     		$("#buttons_inport_ftp .l-btn-text").text("确定导入");
	     		
	        	//var resultObj = eval("[" + data.activeElement.innerText + "]")[0];
	        	var resultObj = JSON.parse(data.slice(data.indexOf(">") + 1,data.indexOf("</")));
	            if(resultObj.backValue === true)
	            {
		            $("#fileName_ftp").val($('#file_ftp').val());
	            	$('#import_link_ftp').window('close'); 
	            	$('#datagrid_ftp').datagrid('reload');
	            	$.messager.alert('提示',"<p>导入成功！</p>", 'info');
	            }
	            else if(resultObj.backValue === false)
	            {
		            $("#fileName_ftp").val($('#file_ftp').val());
	            	//$.messager.alert('错误',"<p>导入失败!所选文件内容为空或存在异常！</p>","error");
	            	$.messager.alert('错误',"<p>" + resultObj.errorDesc + "</p>","error"); 
	            }
	            else
	            {
		            $("#fileName_ftp").val($('#file_ftp').val());
	            	$.messager.alert('错误',"<p>导入失败！" + resultObj.backValue + "</p>", "error"); 
	            }
	        },
	        error: function(data, status, e){ 
	            $("#fileName_ftp").val($('#file_ftp').val());
	     		$("#buttons_inport_ftp .easyui-linkbutton").linkbutton("enable");
	     		$("#buttons_inport_ftp .l-btn-text").text("确定导入");
	     		
	        	$.messager.alert('错误',"<p>导入失败!</p>","error");
	        }
	    });
	}
	
	function onSearch_ftp(){
		$('#datagrid_ftp').datagrid('reload');
	}
	
	var loading_point = {
			timer:null,
			len:3,
			count:0
		};
	function loading1()
	{
	 	if(loading_point.count < loading_point.len)
		{
			loading_point.count++;
			$("#progressbar_point1").text($("#progressbar_point1").text() + ".");
		}else
		{
			loading_point.count = 0;
			$("#progressbar_point1").text("");
		}	
	}
	
	
	
	